package com.bzframework.project.picture.entity;

import com.bzframework.project.picture.enums.ReviewStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.ezorm.rdb.mapping.annotation.EnumCodec;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.api.crud.entity.RecordCreationEntity;
import org.hswebframework.web.api.crud.entity.RecordModifierEntity;
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
import org.hswebframework.web.crud.generator.Generators;

import javax.persistence.Column;
import javax.persistence.Table;
import java.sql.JDBCType;

/**
 * @Author bingzhong
 * @Date 2025/1/15 17:19
 * @Description
 */
@Table(name = "picture")
@Getter
@Setter
@Schema(description = "图片实体类")
@Comment("图片")
@EnableEntityEvent // 开启实体类crud事件
public class PictureEntity extends GenericEntity<String>
// 实现这2个接口标记此实体类需要记录创建人修改人信息，在crud时会自动填充对应的信息。
        implements RecordCreationEntity, RecordModifierEntity {

    @Column(length = 1024, nullable = false)
    @Schema(description = "路径")
    private String url;

    @Column(length = 128, nullable = false)
    @Schema(description = "图片名称")
    private String name;

    @Column(length = 512)
    @Schema(description = "简介")
    private String introduction;

    @Column(length = 64)
    @Schema(description = "分类")
    private String category;

    @Column(length = 512)
    @Schema(description = "标签")
    private String tags;

    @Column
    @ColumnType(javaType = Integer.class, jdbcType = JDBCType.BIGINT)
    @Schema(description = "图片大小")
    private Integer picSize;

    @Column
    @Schema(description = "图片宽度")
    @ColumnType(javaType = Integer.class, jdbcType = JDBCType.INTEGER)
    private Integer picWidth;

    @Column
    @Schema(description = "图片高度")
    @ColumnType(javaType = Integer.class, jdbcType = JDBCType.INTEGER)
    private Integer picHeight;

    @Column
    @Schema(description = "图片比例")
    @ColumnType(javaType = Double.class, jdbcType = JDBCType.DOUBLE)
    private Double picScale;

    @Column(length = 32)
    @Schema(description = "图片格式")
    private String picFormat;

    @Column
    @Schema(description = "审核状态")
    @DefaultValue("reviewing")
    @EnumCodec
    @ColumnType(javaType = String.class)
    private ReviewStatusEnum reviewStatus;

    @Column(length = 512)
    @Schema(description = "审核信息")
    private String reviewMessage;

    @Column(length = 64)
    @Schema(description = "审核ID")
    private String reviewId;

    @Column
    @Schema(description = "审核时间")
    private Long reviewTime;

    // 平台ID长度统一64,创建人不为空,不可修改
    @Column(length = 64, nullable = false, updatable = false)
    @Schema(description = "创建人ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String creatorId;

    @Column(nullable = false, updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    private Long createTime;

    @Column(length = 64, nullable = false)
    @Schema(description = "修改人ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String modifierId;

    @Column(nullable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "修改时间", accessMode = Schema.AccessMode.READ_ONLY)
    private Long modifyTime;

}
